# 名称:zyl
# 时间2022/12/27  11:15

from time import sleep
from appium.webdriver.common.mobileby import MobileBy as By
from pages.base_page import BasePage

class MinePage(BasePage):
    # 定位器

    # 我的
    mine_locator = (
    By.XPATH, '//android.widget.RelativeLayout/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]')
    # 更多
    more_locator = (By.XPATH, '//android.widget.ImageView[@resource-id=\"com.gfeng.daydaycook:id/menuIv\"]')
    # 设置
    set_locator = (By.XPATH, '//android.widget.TextView[@text=\"设置\"]')
    # 个人资料
    data_locator = (By.XPATH, '//android.widget.RelativeLayout[@resource-id=\"com.gfeng.daydaycook:id/detailLayout\"]')
    # 个人简介
    profile_locator = (By.XPATH, '//android.widget.EditText[@resource-id=\"com.gfeng.daydaycook:id/edt_intro\"]')
    # 保存
    save_locator = (By.XPATH, '//android.widget.TextView[@resource-id=\"com.gfeng.daydaycook:id/rightButton\"]')
    # 清空缓存
    cache_locator = (By.XPATH, '//android.widget.ImageView[@resource-id=\"com.gfeng.daydaycook:id/img_right1\"]')
    # 清空
    empty_locator = (By.XPATH, '//android.widget.Button[@resource-id=\"android:id/button1\"]')
    # 接收消息通知
    receive_locator = (By.XPATH, '//android.widget.Switch[@resource-id=\"com.gfeng.daydaycook:id/switchCompat\"]')
    # 推荐好友
    recommend_locator = (By.XPATH,
                         '//android.widget.RelativeLayout[@resource-id=\"com.gfeng.daydaycook:id/shareLayout\"]/android.widget.ImageView[1]')
    # 微信好友
    wechat_locator = (By.XPATH, '//android.widget.TextView[@text=\"微信好友\"]')

    # 朋友圈
    moments_locator = (By.XPATH, '//android.widget.TextView[@text=\"朋友圈\"]')

    # 新浪微博
    weibo_locator = (By.XPATH, '//android.widget.TextView[@text=\"新浪微博\"]')

    # 复制链接
    copy_locator = (By.XPATH, '//android.widget.TextView[@text=\"复制链接\"]')

    # 关于我们
    about_locator = (By.XPATH, '//android.widget.ImageView[@resource-id=\"com.gfeng.daydaycook:id/img_right5\"]')

    # 跳转到设置界面
    def set_jump(self):

        self.driver.find_element(*self.mine_locator).click()  # 点击我的
        sleep(2)
        self.driver.find_element(*self.more_locator).click()  # 点击更多
        sleep(2)
        self.driver.find_element(*self.set_locator).click()  # 点击设置
        sleep(2)

    # 跳转到个人简介界面
    def data_jump(self):

        sleep(2)
        self.driver.find_element(*self.data_locator).click()  # 点击个人简介

    # 修改个人简介
    def profile_modify(self,text):

        sleep(2)
        self.driver.find_element(*self.profile_locator).send_keys(text)  # 在个人简介输入框输入信息

    # 保存
    def profile_save(self):

        sleep(2)
        self.driver.find_element(*self.save_locator).click()  # 点击保存

    # 清空缓存
    def cache_empty(self):

        sleep(2)
        self.driver.find_element(*self.cache_locator).click()  # 点击清空缓存

    # 清空
    def empty(self):

        sleep(2)
        self.driver.find_element(*self.empty_locator).click()  # 点击清空

    # 点击接收消息通知
    def receive_close(self):

        sleep(2)
        self.driver.find_element(*self.receive_locator).click()  # 关闭接收消息通知

    # 点击推荐好友
    def recommend_friends(self):

        sleep(2)
        self.driver.find_element(*self.recommend_locator).click()  # 点击推荐好友

    # 点击微信好友
    def wechat_friends(self):

        sleep(2)
        self.driver.find_element(*self.wechat_locator).click()  # 点击微信好友

    # 点击朋友圈
    def moments_click(self):

        sleep(2)
        self.driver.find_element(*self.moments_locator).click()  # 点击朋友圈

    # 点击新浪微博
    def sina_weibo(self):

        sleep(2)
        self.driver.find_element(*self.weibo_locator).click()  # 点击新浪微博

    # 点击复制链接
    def copy_link(self):

        sleep(2)
        self.driver.find_element(*self.copy_locator).click()  # 点击复制链接

    # 点击关于我们
    def we_click(self):

        sleep(2)
        self.driver.find_element(*self.about_locator).click()  # 点击关于我们
        sleep(2)